import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { TMarketTwo } from "../../../Message/Db/Tables/TMarketTwo";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
import { Language } from "../../../extend/language/Language";
import { HotSellInfo } from "../view/market/HotSellInfo";
type int = number;
//class MarketTwoConfig
    
    export  class MarketTwoConfig
    {
        constructor()
        {
            
            this._allInfoMap = new Map<any, any> /* flash.utils.Dictionary */();
            this._sellInfoMap = new Map<any, any> /* flash.utils.Dictionary */();
            this._seekBuyInfoMap = new Map<any, any> /* flash.utils.Dictionary */();
            this._marketTwoSellInfoArr = [];
            if (MarketTwoConfig._instance != null) 
            {
                throw new Error("MarketTwoConfig单例");
            }
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_market_two.json");
            this.write(loc1);
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TMarketTwo();
                loc1.career = loc2.career;
                loc1.category = loc2.category;
                loc1.color = loc2.color;
                loc1.codeList = StringHelper.getString(loc2.codeList);
                loc1.codeRemove = StringHelper.getString(loc2.codeRemove);
                loc1.oneId = loc2.oneId;
                loc1.twoId = loc2.twoId;
                loc1.twoIndex = loc2.twoIndex;
                loc1.twoName = StringHelper.getString(loc2.twoName);
                loc1.typeList = StringHelper.getString(loc2.typeList);
                loc1.marketType = loc2.marketType;
                if (loc1.marketType != 0) 
                {
                    if (loc1.marketType == 1) 
                    {
                        this._seekBuyInfoMap[loc1.oneId + "_" + loc1.twoIndex] = loc1;
                    }
                }
                else 
                {
                    this._sellInfoMap[loc1.oneId + "_" + loc1.twoIndex] = loc1;
                    if (loc1.twoName == Language.getString(90265)) 
                    {
                        this.coinOneIdx = loc1.oneId;
                        this.coinTwoIdx = loc1.twoIndex;
                    }
                    this._marketTwoSellInfoArr.push(loc1);
                }
                this._allInfoMap[loc1.oneId + "_" + loc1.twoIndex] = loc1;
            }
            return;
        }

        public MarketTwoConfig.get allInfoMap(): Map<any, any> /* flash.utils.Dictionary */
        {
            return this._allInfoMap;
        }

        public MarketTwoConfig.get secondSellInfoTagMap(): Map<any, any> /* flash.utils.Dictionary */
        {
            return this._sellInfoMap;
        }

        public MarketTwoConfig.get secondSeekInfoTagMap(): Map<any, any> /* flash.utils.Dictionary */
        {
            return this._seekBuyInfoMap;
        }

        public getMarketTwoSellInfo(arg1: int, arg2: int): TMarketTwo
        {
            return this._sellInfoMap[arg1 + "_" + arg2];
        }

        public getMarketTwoSeekInfo(arg1: int, arg2: int): TMarketTwo
        {
            return this._seekBuyInfoMap[arg1 + "_" + arg2];
        }

        public getMarketSeekSubTagsByOneid(arg1: int): Map<any, any> /* flash.utils.Dictionary */
        {
            var loc2=null;
            var loc1=new Map<any, any> /* flash.utils.Dictionary */();
            var loc3=0;
            var loc4=this._seekBuyInfoMap;
            for(loc2 of loc4) 
            {
                if (loc2.oneId != arg1) 
                {
                    continue;
                }
                loc1[loc2.oneId + "_" + loc2.twoIndex] = loc2;
            }
            return loc1;
        }

        public getIndexSellInfoByName(arg1: string): HotSellInfo
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            while (loc3 < this._marketTwoSellInfoArr.length) 
            {
                if (this._marketTwoSellInfoArr[loc3]) 
                {
                    loc2 = this._marketTwoSellInfoArr[loc3];
                    if (arg1 == loc2.twoName) 
                    {
                        loc1 = new HotSellInfo();
                        loc1.oneIndex = (loc2.oneId - 1);
                        --loc1.twoIndex;
                        if (arg1 != Language.getString(90261)) 
                        {
                            if (arg1 != Language.getString(90263)) 
                            {
                                loc1.name = loc2.twoName;
                            }
                            else 
                            {
                                loc1.name = Language.getString(90264);
                            }
                        }
                        else 
                        {
                            loc1.name = Language.getString(90262);
                        }
                        return loc1;
                    }
                }
                ++loc3;
            }
            return null;
        }

        public static get instance(): MarketTwoConfig
        {
            if (MarketTwoConfig._instance == null) 
            {
                MarketTwoConfig._instance = new MarketTwoConfig();
            }
            return MarketTwoConfig._instance;
        }

        /* internal */ /* var */_allInfoMap: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_sellInfoMap: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_seekBuyInfoMap: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_marketTwoSellInfoArr: Array<any>;

        public /* var */coinOneIdx: int;

        public /* var */coinTwoIdx: int;

        /* internal */ static /* var */_instance: MarketTwoConfig;
    }
